using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class PlayerGroundState : PlayerState
{
    public PlayerGroundState(Player player, PlayerStateMachine playerStateMachine, string animBoolName) : base(player, playerStateMachine, animBoolName)
    {
    }

    public override void Enter()
    {
        base.Enter();
        PlayerManager.Instance.player.entityFx. MakeTransParent(false);
    }

    public override void Exit()
    {
        base.Exit();
    }

    public override void Update()
    {
        base.Update();
        if (!player.isGround())
            playerStateMachine.ChangeState(player.playerAirState);
        if (Input.GetKeyDown(KeyCode.Space) && player.isGround())
            playerStateMachine.ChangeState(player.playerJumpState);
        if (Input.GetMouseButton(0))
            playerStateMachine.ChangeState(player.playerPrimaryAttack);
        if (Input.GetKeyDown(KeyCode.K)&&player.skill.parrySkill.parryUnlocked)
            playerStateMachine.ChangeState(player.playerCounterAttackState);
        if (Input.GetMouseButtonDown(1)&&HasNoSword()) 
            playerStateMachine.ChangeState(player.playerAimSwordState);
        if (Input.GetKeyDown(KeyCode.R)&&player.skill.blackDongSkill.CanUseSkill())
            playerStateMachine.ChangeState(player.playerBlackDongState);
    }
    private bool HasNoSword()
    {
        if (!player.sword)
            return true;
        player.sword.GetComponent<SwordSkillController>().ReturnSword();
        return false;
    }
}
